blob: bff8848c398d0a3c053ff84ce67eabe835e07dc5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import { get } from "$lib/utils";
import { error } from "@sveltejs/kit";
export const load = async ({
cookies,
depends,
params: { username },
parent,
}) => {
depends("app:user");
try {
const subject = await get(`/users/${username}`);
const { user } = await parent();
const expires = new Date();
expires.setSeconds(expires.getSeconds() + 380 * 24 * 60 * 60);
cookies.set("username", username, { path: "/", expires, httpOnly: false });
return { subject, user };
} catch (e) {
error(500, "Unable to retrieve user account data");
}
};
|